package com.yunmang.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yunmang.R;
import com.yunmang.entity.ExceptionQueryBean;
import com.yunmang.entity.SendBatchBean;
import com.yunmang.utils.ViewHolderUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/5/26.
 */
public class PiciManagerAdapter extends BaseAdapter{

    private Context context;
    private List<SendBatchBean.ModelBean> dataLsit;

    public PiciManagerAdapter(Context context, List<SendBatchBean.ModelBean> dataLsit) {
        this.context = context;
        this.dataLsit = dataLsit;
    }

    @Override
    public int getCount() {
        return dataLsit.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        SendBatchBean.ModelBean modelBean = dataLsit.get(i);
        if(convertView==null)
            convertView=View.inflate(context, R.layout.item_pici,null);
        TextView tv_pici = ViewHolderUtils.get(convertView, R.id.tv_pici);
        TextView tv_start = ViewHolderUtils.get(convertView, R.id.tv_start);
        TextView tv_end = ViewHolderUtils.get(convertView, R.id.tv_end);
        TextView tv_pici_num = ViewHolderUtils.get(convertView, R.id.tv_pici_num);
        TextView tv_pici_card = ViewHolderUtils.get(convertView, R.id.tv_pici_card);
        TextView tv_fache_date = ViewHolderUtils.get(convertView, R.id.tv_fache_date);
        TextView tv_status = ViewHolderUtils.get(convertView, R.id.tv_status);
        ImageView iv_status = ViewHolderUtils.get(convertView, R.id.iv_status);
        tv_pici.setText(modelBean.getBatchNumber());
        tv_start.setText(modelBean.getDepartName());
        tv_end.setText(modelBean.getNextDepartName());
        tv_fache_date.setText(modelBean.getSendDate().substring(0,10));
        tv_pici_card.setText(modelBean.getPlate());
        tv_pici_num.setText(modelBean.getQuantity()+"");
        int type = modelBean.getBatchStatus();
        Log.e("type",type+"");
        if(type==0){
            iv_status.setImageResource(R.mipmap.icon_ycgl40_wtg);
            tv_status.setText("未交接");
            tv_status.setTextColor(context.getResources().getColor(R.color.red0));
        }else{
            iv_status.setImageResource(R.mipmap.icon_ycgl40_tg);
            tv_status.setText("已交接");
            tv_status.setTextColor(context.getResources().getColor(R.color.green3));
        }
        return convertView;
    }


    public  void refresh(List<SendBatchBean.ModelBean> datalist){
        this.dataLsit=datalist;
        notifyDataSetChanged();
    }
}
